package com.googlecode.flex_solder.collections  {
  /**
   * $Id: AssociativeArrayCollection.as 25 2009-02-17 01:43:57Z fuller.sethm $
   * 
   */

  import mx.collections.ArrayCollection;

  public class AssociativeArrayCollection extends ArrayCollection {
    private var _fieldName:String = null;

    protected var associativeArray:Object = new Object();

    public function AssociativeArrayCollection() {

    }

    public function buildAssociativeArray():void {
    }

    override public function addItemAt(item:Object, index:int):void {
      super.addItemAt(item, index);
      if (null != item) {
	associativeArray[item[_fieldName]] = item;
      }
    }

    public function getItemByKey(keyValue:Object):Object {
      var item:Object = associativeArray[keyValue];

      return item;

    }

    public function get fieldName():String {
       return _fieldName;
    }

    [Bindable]
    public function set fieldName(fieldName:String):void {
       _fieldName = fieldName;
    }

  }
}